package com.gaea.auth.service.impl;

import com.gaea.auth.feign.IUserService;
import com.gaea.auth.vo.GaeaUserDetails;
import com.gaea.base.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @author bjsonghongxu
 * @create 2018-03-29 16:28
 **/
@Service("userDetailsService")
public class UserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    private IUserService iUserService;

    @Override
    public GaeaUserDetails loadUserByUsername(String nickName) throws UsernameNotFoundException {
        UserVo uv = new UserVo(nickName,null);
        UserVo userVo = iUserService.login(uv);
        return new GaeaUserDetails(userVo);
    }
}
